package com.itheima.reggie.controller;


import com.itheima.reggie.common.R;
import com.itheima.reggie.utils.FileUploader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/common")
public class CommonController {
    @Autowired
    private FileUploader fileUploader;
    //图片上传 minio
    @PostMapping("upload")
    public R<String> upload(MultipartFile file){
        String fileName = null;
        try {
            fileName = fileUploader.upload(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.success(fileName);
    }

}
